#include<stdio.h>
#define DEFAULT_SIZE 105    //测试无参宏定义
#define DECL_ARRAY(ARRAY_NAME,ARRAY_SZ) int ARRAY_NAME[ARRAY_SZ]={} //测试带参宏定义
DECL_ARRAY(p,DEFAULT_SIZE);//展开后：int p[105]={};
DECL_ARRAY(vis,DEFAULT_SIZE);//展开后：int vis[105]={};
void Print(int n)
{
    for(int i=0;i<n;i=i+1){
        printf("%d ",p[i]);
    }
    printf("\n");
}
void DFS(int pos,int n)
{
    if(pos == n){
        Print(n);//Comment this line to see the difference
        /*
        Comment these lines to see the difference
        */
        return;
    }
    for(int i=1;i<=n;i=i+1){
        if(vis[i]){continue;}
        p[pos] = i;
        vis[i] = 1;
        DFS(pos+1,n);
        vis[i] = 0;
    }
}
int main()
{
    int n = 0;
    
    scanf("%d",&n);
    DFS(0,n);
    return 0;
}